#ifndef COUNTDOWNTIMER_H
#define COUNTDOWNTIMER_H

#include <QObject>
#include <QTimer>
#include <QDateTime>
#include <QDebug>

class CountdownTimer : public QObject
{
    Q_OBJECT
    Q_PROPERTY(QString days READ days NOTIFY countdownChanged)
    Q_PROPERTY(QString hours READ hours NOTIFY countdownChanged)
    Q_PROPERTY(QString minutes READ minutes NOTIFY countdownChanged)
    Q_PROPERTY(QString seconds READ seconds NOTIFY countdownChanged)
    Q_PROPERTY(int targetYear READ targetYear NOTIFY countdownChanged)
    Q_PROPERTY(bool isNewYear READ isNewYear NOTIFY countdownChanged)

public:
    explicit CountdownTimer(QObject *parent = nullptr);
    
    QString days() const { return m_days; }
    QString hours() const { return m_hours; }
    QString minutes() const { return m_minutes; }
    QString seconds() const { return m_seconds; }
    int targetYear() const { return m_targetYear; }
    bool isNewYear() const { return m_isNewYear; }

signals:
    void countdownChanged();

private slots:
    void updateCountdown();

private:
    QTimer *m_timer;
    QString m_days;
    QString m_hours;
    QString m_minutes;
    QString m_seconds;
    int m_targetYear;
    bool m_isNewYear;
    
    QString formatNumber(int number);
};

#endif // COUNTDOWNTIMER_H

